package cn.webrx.wxs.mapper;

import cn.webrx.wxs.entity.FileCate;
import cn.webrx.wxs.vo.VoFileCate;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

public interface FileCateMapper {

    public List<VoFileCate> queryCate();
    @Delete("delete from ws_filecate where id = #{id}")
    public int delById(int id);
    @Select("select count(0) from ws_filecate where pid = #{id}")
    public int existSubCateById(int id);

    @Insert("insert into ws_filecate(pid,name,sort) values(#{pid},#{name},#{sort})")
    public int save(FileCate fc);

    @Select("select * from ws_filecate where id = #{id}")
    public FileCate queryById(int id);

    @Select("select * from ws_filecate where id = #{pid}")
    public FileCate queryParentById(int pid);

    @Select("SELECT id,name,pid,level from (SELECT id,NAME,pid,LEVEL,CONCAT(path,',',id) ss FROM ws_filecate ORDER BY sort ASC,ss ASC) nn")
    public List<FileCate> queryAllCate();

    @Update("update ws_filecate set name=#{name},pid=#{pid},sort=#{sort},level=#{level},path=#{path} where id = #{id}")
    public int update(FileCate fc);


}